package me.softwareengineer.guice.rendering.domain.referenece;

import org.apache.commons.lang3.StringUtils;

/**
 * Represents reference to attached resources
 * 
 * @author yadtahir
 * 
 */
public class AttachmentResourceReference extends ResourceReference {

	private static final String QUERY_STRING = "queryString";

	/**
	 * Creates an attachment resource reference
	 * 
	 * @param reference
	 *            the reference to the attachment
	 */
	public AttachmentResourceReference(String reference) {
		super(reference, ResourceType.ATTACHMENT);
	}

	/**
	 * @return the query string for specifying parameters that will be used in
	 *         the rendered URL or null if no query string has been specified.
	 *         Example: "mydata1=5&mydata2=Hello"
	 */
	public String getQueryString() {
		return (String) getMetaData(QUERY_STRING);
	}

	/**
	 * @param queryString
	 *            see {@link #getQueryString()}
	 */
	public void setQueryString(String queryString) {
		if (!StringUtils.isEmpty(queryString)) {
			this.addMetaData(QUERY_STRING, queryString);
		}
	}
}
